package jy.game.components.save;


import jy.game.BasePojo;
import wx.xml.simpleframework.xml.Attribute;
import wx.xml.simpleframework.xml.Element;
import wx.xml.simpleframework.xml.Root;

@Root(name = "gamesave")
public class JyGameSave extends BasePojo {

    @Attribute(name = "name") public       String           Name       = "save";
    @Attribute(name = "newbieTask") public String           NewbieTask = "";
    @Element
    public                                 JyGameSaveRole[] Roles;


    // (get) Token: 0x060003C3 RID: 963 RVA: 0x0002A3BC File Offset: 0x000285BC
    // [XmlIgnore]
//    public DateTime Time() {
//        {
//            String text = this.GetValueByKey("date").Trim();
//            if (text.Length > 19) {
//                text = text.SubString(text.Length - 19, 19);
//                text = text.Replace("0000-", "0001-");
//            }
//            return DateTime.ParseExact(text, "yyyy-MM-dd HH:mm:ss", CultureInfo.CurrentCulture);
//        }
//    }
    @Element
    public                      JyGameSaveRole[]      Follows;
    @Element(name = "i") public JyGameSaveItem[]      GameItems;
    @Element
    public                      JyGameSaveItem[]      XiangziItems;
    @Element(name = "k") public JyGameSaveKeyValues[] KeyValues;
    @Element
    public                      JyGameSaveRole[]      Temps;


    //    public static DateTime GetTimeByKey(String key) {
//        if (key.Length > 19) {
//            key = key.SubString(key.Length - 19, 19);
//            key = key.Replace("0000-", "0001-");
//        }
//        return DateTime.ParseExact(key, "yyyy-MM-dd HH:mm:ss", CultureInfo.CurrentCulture);
//    }
    @Attribute(name = "information") public String Information = "";

    public static String ToString2(String[] array) {
        if (array.length > 7) {
            String text  = "";// CommonSettings.DateToGameTime(JyGameSave.GetTimeByKey(array[2]));
            String text2 = "难度:<color='white'>简单</color>";
            switch (array[4]) {
                case "hard":
                    text2 = "<color='yellow'>难度:进阶</color>";
                    break;
                case "crazy":
                    text2 = "<color='red'>难度:炼狱</color>";
                    break;
                case "True":
                    text2 = "<color='magenta'>难度:无悔</color>";
                    break;
                default:
                    break;
            }

            String text3 = "周目:" + array[5];
            return String.format("%s  <color='yellow'>(%s)</color>  队伍%s人\n%s\n%s<color='white'>\t\t%s\n当前位置:%s</color>",

                array[1],
                text,
                array[3],
                text2,
                text3,
                array[6],
                array[7]
            );
        }
        return "";
    }

    // (get) Token: 0x060003C0 RID: 960 RVA: 0x00004123 File Offset: 0x00002323
    @Override public /*override*/ String getPK() {
        {
            return this.Name;
        }
    }

    @Override public /*override*/ void initBind() {
        for (JyGameSaveRole gameSaveRole : this.Roles) {
        }
    }

    public String GetValueByKey(String key) {
        for (JyGameSaveKeyValues gameSaveKeyValues : this.KeyValues) {
            if (gameSaveKeyValues.key == key) {
                return gameSaveKeyValues.value;
            }
        }
        return null;
    }

    // (get) Token: 0x060003C4 RID: 964 RVA: 0x0000412B File Offset: 0x0000232B
    // [XmlIgnore]
    public String GameMode() {
        {
            if (this.GetValueByKey("mode") == null) {
                return "normal";
            }
            return this.GetValueByKey("mode");
        }
    }

    // (get) Token: 0x060003C5 RID: 965 RVA: 0x0000414B File Offset: 0x0000234B
    // [XmlIgnore]
    public boolean AutoSaveOnly()

    {

        return this.GetValueByKey("AutoSaveOnly") != null && Boolean.parseBoolean(this.GetValueByKey("AutoSaveOnly"));

    }

    // (get) Token: 0x060003C6 RID: 966 RVA: 0x0000416C File Offset: 0x0000236C
    // [XmlIgnore]
    public int Round() {
        {
            if (this.GetValueByKey("round") == null) {
                return 1;
            }
            return Integer.parseInt(this.GetValueByKey("round"));
        }
    }

    // (get) Token: 0x060003C7 RID: 967 RVA: 0x0000418D File Offset: 0x0000238D
    // [XmlIgnore]
    public String Locate() {
        {
            return this.GetValueByKey("currentBigMap");
        }
    }

    public /*override*/ String ToString() {
        String text  = "江湖一年一月一日"; //CommonSettings.DateToGameTime(this.Time);
        String text2 = "难度:<color='white'>简单</color>";
        if (this.GameMode() == "hard") {
            text2 = "<color='yellow'>难度:进阶</color>";
        }
        if (this.GameMode() == "crazy") {
            text2 = "<color='red'>难度:炼狱</color>";
        }
        if (this.AutoSaveOnly()) {
            text2 = "<color='magenta'>难度:无悔</color>";
        }
        String text3 = "周目:" + this.Round();
        return String.format("%s  <color='yellow'>(%s)</color>  队伍%s人\n%s\n%s<color='white'>\t\t%s\n当前位置:%s</color>",

            this.Roles[0].name,
            text,
            this.Locate(),
            text2,
            text3,
            this.GetValueByKey("currentNick"),
            this.Roles.length
        );
    }
}
